<template>
  <section>
    <list-table :loading="loading"
                :data="data"
                :total='total'
                :filterAnd="filterAnd"
                :currentPage="currentPage"
                :size="size"
                @load="getList">
      <ym-title-control has-back
                        :title="`当前用户名：${title}`"></ym-title-control>
    </list-table>
  </section>
</template>
<script>
import { cloneDeep } from 'lodash'
import { paramsFilter } from '@/utils/params-filter'
import queryMixins from '@/views/mixins/query'

export default {
  mixins: [queryMixins],
  components: {
    listTable: () => import('./component/list-table.vue')
  },
  data () {
    return {
      title: '',
      busiName: 'UsersTickets'
    }
  },
  async mounted () {
    let { userId } = this.$route.query
    this.handlerSearch()
    this.$command.execute({
      api: `/api/SelectByConds/AppUsers`,
      params: {
        index: 0,
        pageSize: 1
      },
      data: {
        "CONDS": ['id', userId],
        "COLUMNS": ["id", "用户名称", "登陆手机"]
      }
    }).then(async res => {
      if (res.data.length) {
        this.title = `${res.data[0].用户名称}(${res.data[0].登陆手机})`
      }
    })
  },
  methods: {
    handlerSearch (e) {
      let { userId } = this.$route.query
      let form = cloneDeep(this.form)
      this.filterAnd = paramsFilter(form, {
      })
      if (userId) {
        this.filterAnd.push('用户', userId)
      }
      this.currentPage = 1
      if (!e && this.$route.query.page) {
        this.currentPage = Number(this.$route.query.page)
      }
      if (this.$route.query.size) {
        this.perPage = Number(this.$route.query.size)
      }
      this.getList()

    },
    getList (page, size) {
      this.currentPage = page || this.currentPage
      this.size = size || this.size
      this.loading = true
      this.$command.execute({
        api: `/api/SelectByConds/${this.busiName}`,
        params: {
          index: (Number(this.currentPage) - 1) * this.size,
          pageSize: this.size,
        },
        data: {
          "CONDS": [].concat(this.filterAnd),
          "ORDER": ['optdate DESC'],
          "COLUMNS": ["id", "NodeType", "nodetype", "企业地址", "企业电话", "发票邮箱", "开户银行", "抬头名称", "抬头类型", "抬头类型:id|名称 type", "状态", "用户", "税号", "银行帐号"]
        }
      }).then(async res => {
        this.loading = false
        this.data = res.data
        this.total = await this.$store.dispatch('app/getPageTotal', { busiName: this.busiName, filterAnd: this.filterAnd })

      })
    }
  }
}
</script>
<style lang="scss" scoped>
.add-btn {
  margin-bottom: 10px;
}
/deep/.el-tabs--border-card > .el-tabs__content {
  padding: 10px 15px;
}
</style>
